/*  1:   */ package org.intellij.plugins.relaxNG.model.resolve;
/*  2:   */ 
/*  3:   */

import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.impl.include.FileIncludeManager;
import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xml.DomManager;
import org.intellij.plugins.relaxNG.compact.RncFileType;
import org.intellij.plugins.relaxNG.xml.dom.RngGrammar;
import org.jetbrains.annotations.NotNull;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */
/* 13:   */
/* 14:   */
/* 15:   */
/* 16:   */
/* 17:   */
/* 18:   */ 
/* 19:   */ public class RelaxIncludeIndex
/* 20:   */ {
/* 21:   */   public static boolean processForwardDependencies(XmlFile paramXmlFile, PsiElementProcessor<XmlFile> paramPsiElementProcessor)
/* 22:   */   {
/* 23:26 */     VirtualFile localVirtualFile = paramXmlFile.getVirtualFile();
/* 24:27 */     if (localVirtualFile == null) {
/* 25:28 */       return paramPsiElementProcessor.execute(paramXmlFile);
/* 26:   */     }
/* 27:30 */     Project localProject = paramXmlFile.getProject();
/* 28:31 */     VirtualFile[] arrayOfVirtualFile = FileIncludeManager.getManager(localProject).getIncludedFiles(localVirtualFile, true);
/* 29:   */     
/* 30:33 */     return a(paramXmlFile, arrayOfVirtualFile, paramPsiElementProcessor);
/* 31:   */   }
/* 32:   */   
/* 33:   */   public static boolean processBackwardDependencies(@NotNull XmlFile paramXmlFile, PsiElementProcessor<XmlFile> paramPsiElementProcessor)
/* 34:   */   {
/* 35:37 */     if (paramXmlFile == null) {
/* 36:37 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/model/resolve/RelaxIncludeIndex", "processBackwardDependencies" }));
/* 37:   */     }
/* 38:37 */     VirtualFile localVirtualFile = paramXmlFile.getVirtualFile();
/* 39:38 */     if (localVirtualFile == null) {
/* 40:39 */       return paramPsiElementProcessor.execute(paramXmlFile);
/* 41:   */     }
/* 42:41 */     Project localProject = paramXmlFile.getProject();
/* 43:42 */     VirtualFile[] arrayOfVirtualFile = FileIncludeManager.getManager(localProject).getIncludingFiles(localVirtualFile, true);
/* 44:   */     
/* 45:44 */     return a(paramXmlFile, arrayOfVirtualFile, paramPsiElementProcessor);
/* 46:   */   }
/* 47:   */   
/* 48:   */   private static boolean a(PsiFile paramPsiFile, VirtualFile[] paramArrayOfVirtualFile, PsiElementProcessor<XmlFile> paramPsiElementProcessor)
/* 49:   */   {
/* 50:48 */     Project localProject = paramPsiFile.getProject();
/* 51:49 */     PsiManager localPsiManager = PsiManager.getInstance(localProject);
/* 52:50 */     PsiFile[] arrayOfPsiFile1 = (PsiFile[])ContainerUtil.map2Array(paramArrayOfVirtualFile, PsiFile.class, new NullableFunction()
/* 53:   */     {
/* 54:   */       public PsiFile fun(VirtualFile paramAnonymousVirtualFile)
/* 55:   */       {
/* 56:52 */         return this.val$psiManager.findFile(paramAnonymousVirtualFile);
/* 57:   */       }
/* 58:   */     });
/* 59:56 */     for (PsiFile localPsiFile : arrayOfPsiFile1) {
/* 60:57 */       if (!a(localPsiFile, paramPsiElementProcessor)) {
/* 61:58 */         return false;
/* 62:   */       }
/* 63:   */     }
/* 64:61 */     return true;
/* 65:   */   }
/* 66:   */   
/* 67:   */   private static boolean a(PsiFile paramPsiFile, PsiElementProcessor<XmlFile> paramPsiElementProcessor)
/* 68:   */   {
/* 69:65 */     FileType localFileType = paramPsiFile.getFileType();
/* 70:66 */     if ((localFileType == XmlFileType.INSTANCE) && (isRngFile(paramPsiFile)))
/* 71:   */     {
/* 72:67 */       if (!paramPsiElementProcessor.execute((XmlFile)paramPsiFile)) {
/* 73:68 */         return false;
/* 74:   */       }
/* 75:   */     }
/* 76:70 */     else if ((localFileType == RncFileType.getInstance()) && 
/* 77:71 */       (!paramPsiElementProcessor.execute((XmlFile)paramPsiFile))) {
/* 78:72 */       return false;
/* 79:   */     }
/* 80:75 */     return true;
/* 81:   */   }
/* 82:   */   
/* 83:   */   static boolean isRngFile(PsiFile paramPsiFile)
/* 84:   */   {
/* 85:79 */     return ((paramPsiFile instanceof XmlFile)) && (DomManager.getDomManager(paramPsiFile.getProject()).getFileElement((XmlFile)paramPsiFile, RngGrammar.class) != null);
/* 86:   */   }
/* 87:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.model.resolve.RelaxIncludeIndex

 * JD-Core Version:    0.7.0.1

 */